package com.m3839.sdk.ym.ui

import android.app.Activity
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import android.widget.TextView
import com.m3839.sdk.ym.base.YMBaseDialogFragment
import com.m3839.sdk.ym.constant.YMStringConstant
import com.m3839.sdk.ym.ext.getId

/**
 * @description: YMTipDialog
 *
 * @author ChenBaoyang
 * @date 6/16/21 10:35
 */
class YMTipDialogFragment() : YMBaseDialogFragment() {

    private lateinit var contentTv: TextView
    private lateinit var fcmTv: TextView
    private lateinit var knowTv: TextView

    companion object{
        private const val FRAGMENT_TAG = "com.m3839.sdk.ym:tip"

        fun show(activity: Activity) {
            val fragment = YMTipDialogFragment()

            fragment.show(activity.fragmentManager, FRAGMENT_TAG)
        }
    }

    override fun parseArgs() {

    }

    override fun layoutName() = "ym_page_fcm_dialog"

    override fun initView(view: View?) {
        contentTv = view!!.findViewById(getId("tv_content"))
        fcmTv = view.findViewById(getId( "tv_fcm"))
        knowTv = view.findViewById(getId( "tv_know"))

        
    }

    override fun setContent() {
        contentTv.text = YMStringConstant.YM_FCM_CONTENT
        fcmTv.text = YMStringConstant.YM_FCM_ENTER
        knowTv.text = YMStringConstant.YM_FCM_KNOW
    }

    override fun initListener() {
        fcmTv.setOnClickListener {
            YMModeDialogFragment.show(activity,  tag = YMStringConstant.YM_FRAGMENT_TAG_MODE)
        }

        knowTv.setOnClickListener { dismiss() }
    }

    override fun isInterceptBackEvent(event: KeyEvent): Boolean {
        return true
    }
}